<?php $this->import('Header') ?>
	<div style="height: 10px;"></div>
	<div class="well">
		<h3>首页导航设置</h3>
		<ul class="nav nav-tabs">
			<li class="active"><a href="#category" data-toggle="tab">分类导航</a></li>
			<li class=""><a href="#message" data-toggle="tab">留言栏目</a></li>
		</ul>
		<div class="tab-content">
			<div id="message-box"></div>
			<div  id="category" class="tab-pane active in">
				<div id="message-box"></div>
				<form method="post">
					<input type="hidden" name="type" value="<?php echo \Data\Options::TYPE_INDEX_MENU ?>" />
					<label>选择一个分类</label>
					<select id="js-category" name="categoryId"></select>
					<label>友好连接</label>
					<input type="text" name="relink" value="" class="input-xlarge">
					<label>排序</label>
					<input type="number" name="sort" value="" class="input-xlarge">
					<div class="btn-toolbar">
						<button class="btn btn-primary"><i class="icon-save"></i> 添加这个分类到首页导航</button>
					</div>
				</form>
			</div>
			<div  id="message" class="tab-pane ">
				<form method="post">
					<input type="hidden" name="type" value="<?php echo \Data\Options::TYPE_INDEX_MENU_MESSAGE ?>" />
					<label>栏目别名</label>
					<input type="text" name="rename" value="" class="input-xlarge">
					<label>排序</label>
					<input type="number" name="sort" value="" class="input-xlarge">
					<div class="btn-toolbar">
						<button class="btn btn-primary"><i class="icon-save"></i> 添加一个留言栏目到导航</button>
					</div>
				</form>
			</div>
		</div>
		<div class="tab-content">
			<table class="table">
				<tbody><tr>
					<td>导航名称</td>
					<td>友好连接</td>
					<td>导航排序值</td>
					<td>类型</td>
					<td style="width: 160px;">操作</td>
				</tr>
				<?php foreach ($categoryMenu as $val) { ?>
					<?php if ($val['OptionsType'] == \Data\Options::TYPE_INDEX_MENU_MESSAGE)  { ?>
						<td><?php echo $val['Value'] ?> </td>
						<td>message.html</td>
						<td><?php echo $val['Sort'] ?></td>
						<td>留言栏目</td>
						<td>
							<a href="javascript:;" onclick="del(<?php echo $val['Id'] ?>)" class="btn">删除</a>
						</td>
					<?php } else { ?>
					<tr>
						<td><?php echo $val['CategoryName'] ?> </td>
						<td><?php echo $val['Relink'] ?></td>
						<td><?php echo $val['Sort'] ?></td>
						<td>分类导航</td>
						<td>
							<a href="javascript:;" onclick="del(<?php echo $val['Id'] ?>)" class="btn">删除</a>
						</td>
					</tr>
					<?php }?>
				<?php } ?>
				</tbody></table>
		</div>
	</div>
<?php $this->import('Footer') ?>
<script>
	$('#js-category').category({
		pid: 0,
		data: <?php echo json_encode($all) ?>
	});
	function del(id) {
		if (confirm('确定要删除吗？')) {
			$.ajax({
				url: '/Ajax/Options/Del',
				data: {id:id},
				type: 'post',
				dataType: 'json',
				success: function(data) {
					if (data.error) {
						alert(data.data);
					} else {
						window.location.reload();
					}
				}
			});
		}
	}
</script>